import 'package:bloc/bloc.dart';
import 'package:dio/dio.dart';
import 'package:today_app/bloc/news_today/news_today_model.dart';

import 'news_today_event.dart';
import 'news_today_state.dart';

class NewsTodayBloc extends Bloc<NewsTodayEvent, NewsTodayState> {
  NewsTodayBloc() : super(NewsTodayState().init()) {
    on<InitEvent>(_init);
  }

  void _init(InitEvent event, Emitter<NewsTodayState> emit) async {
    /**
     *{
        "reason":"success!",
        "result":{
        "stat":"1",
        "data":[
        {
        "uniquekey":"f3120f14edca2bbe4b6242a0d887a52b",
        "title":"杭州富阳一男子吃“芋头”中毒，医院急诊科抢救",
        "date":"2023-02-25 22:43:00",
        "category":"头条",
        "author_name":"科普社会",
        "url":"https:\/\/mini.eastday.com\/mobile\/230225224304002978465.html",
        "thumbnail_pic_s":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x640_63fa1e777fb16_mwpm_03201609.jpeg",
        "is_content":"1"
        },
        {
        "uniquekey":"dc77a94cbaf48ed5a2ccc808769586cb",
        "title":"小偷攀爬排水管进入居民家，业主后背直冒冷汗",
        "date":"2023-02-25 22:37:00",
        "category":"头条",
        "author_name":"科普社会",
        "url":"https:\/\/mini.eastday.com\/mobile\/230225223718166782912.html",
        "thumbnail_pic_s":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x360_63fa1d1ba1c75_mwpm_03201609.jpeg",
        "thumbnail_pic_s02":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x360_63fa1d1c6469f_mwpm_03201609.jpeg",
        "thumbnail_pic_s03":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x360_63fa1d1d18aa7_mwpm_03201609.jpeg",
        "is_content":"1"
        },
        {
        "uniquekey":"67b9feec766bc7d43dca3448b3f1b3c1",
        "title":"香港铁人三项亚洲杯林鑫瑜、陆美伊摘金",
        "date":"2023-02-25 22:18:00",
        "category":"头条",
        "author_name":"科普社会",
        "url":"https:\/\/mini.eastday.com\/mobile\/230225221850226454179.html",
        "thumbnail_pic_s":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/629x542_63fa18c9a1559_mwpm_03201609.jpeg",
        "is_content":"1"
        },
        {
        "uniquekey":"df8453ef4c846ddf5af5b52f12c4769f",
        "title":"西藏拉萨迎来降雪天气",
        "date":"2023-02-25 22:16:00",
        "category":"头条",
        "author_name":"科普社会",
        "url":"https:\/\/mini.eastday.com\/mobile\/230225221605280122389.html",
        "thumbnail_pic_s":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x290_63fa18229b444_mwpm_03201609.jpeg",
        "thumbnail_pic_s02":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x290_63fa1823305f9_mwpm_03201609.jpeg",
        "thumbnail_pic_s03":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x378_63fa182417982_mwpm_03201609.jpeg",
        "is_content":"1"
        },
        {
        "uniquekey":"d104e437098895e048c3156c1a0a26fb",
        "title":"助力孩子教育 希沃推出网课学习机W2",
        "date":"2023-02-25 22:12:00",
        "category":"头条",
        "author_name":"中国质量新闻网",
        "url":"https:\/\/mini.eastday.com\/mobile\/230225221219601670064.html",
        "thumbnail_pic_s":"",
        "is_content":"1"
        },
        {
        "uniquekey":"3900a41d01a5361da0cfd42bf35ea44d",
        "title":"湖南省微电影大赛“金芙蓉奖”颁奖典礼圆满落幕",
        "date":"2023-02-25 22:11:00",
        "category":"头条",
        "author_name":"科普社会",
        "url":"https:\/\/mini.eastday.com\/mobile\/230225221110181618654.html",
        "thumbnail_pic_s":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x463_63fa16fc3583b_mwpm_03201609.jpeg",
        "thumbnail_pic_s02":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x444_63fa16fd1d52e_mwpm_03201609.jpeg",
        "thumbnail_pic_s03":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x480_63fa16fdb60f6_mwpm_03201609.jpeg",
        "is_content":"1"
        },
        {
        "uniquekey":"580e0728ca91f0a5a537c110e9122485",
        "title":"淄博市精品旅游促进会正式揭牌成立",
        "date":"2023-02-25 21:53:00",
        "category":"头条",
        "author_name":"科普社会",
        "url":"https:\/\/mini.eastday.com\/mobile\/230225215347763844999.html",
        "thumbnail_pic_s":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/550x367_63fa12e9bf68b_mwpm_03201609.jpeg",
        "thumbnail_pic_s02":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/550x349_63fa12ea80d85_mwpm_03201609.jpeg",
        "thumbnail_pic_s03":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/550x318_63fa12eb4c35d_mwpm_03201609.jpeg",
        "is_content":"1"
        },
        {
        "uniquekey":"189a6d8d04919c81a6d73f986d7690ec",
        "title":"周小川谈中国养老金政策：要避免单一化、要算总账",
        "date":"2023-02-25 21:48:00",
        "category":"头条",
        "author_name":"每日看点快看",
        "url":"https:\/\/mini.eastday.com\/mobile\/230225214855552385882.html",
        "thumbnail_pic_s":"",
        "is_content":"1"
        },
        {
        "uniquekey":"84bfaacac52d28713a5767e911517a75",
        "title":"苏州市相城区黄桥街道黄桥村党员冬训“提档升级”",
        "date":"2023-02-25 21:46:00",
        "category":"头条",
        "author_name":"科普社会",
        "url":"https:\/\/mini.eastday.com\/mobile\/230225214601610773737.html",
        "thumbnail_pic_s":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x480_63fa111914565_mwpm_03201609.jpeg",
        "is_content":"1"
        },
        {
        "uniquekey":"0229c756dea30c23c7c85a26babc2b0e",
        "title":"【共话数字碳中和】陶岚：居民减排可视化 从消费端助力低碳转型",
        "date":"2023-02-25 21:45:00",
        "category":"头条",
        "author_name":"每日看点快看",
        "url":"https:\/\/mini.eastday.com\/mobile\/230225214521081268979.html",
        "thumbnail_pic_s":"https:\/\/dfzximg02.dftoutiao.com\/news\/20230225\/20230225214521_a90903299922533a3b5f218cd5de7200_1_mwpm_03201609.jpeg",
        "is_content":"1"
        },
        {
        "uniquekey":"d9f7ca728020893cec1ad8d0fd3e43d7",
        "title":"南通市北护理院党支部打造“15分钟冬训学习圈”",
        "date":"2023-02-25 21:36:00",
        "category":"头条",
        "author_name":"科普社会",
        "url":"https:\/\/mini.eastday.com\/mobile\/230225213641242401309.html",
        "thumbnail_pic_s":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x480_63fa0ee735340_mwpm_03201609.jpeg",
        "thumbnail_pic_s02":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x480_63fa0ee7ce3f3_mwpm_03201609.jpeg",
        "thumbnail_pic_s03":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x480_63fa0ee8b40ff_mwpm_03201609.jpeg",
        "is_content":"1"
        },
        {
        "uniquekey":"d430b6cd53e9f3faf6bfc5e9c6d5ec61",
        "title":"苏州姑苏区白洋湾街道路南社区开展“冬训”活动",
        "date":"2023-02-25 21:32:00",
        "category":"头条",
        "author_name":"科普社会",
        "url":"https:\/\/mini.eastday.com\/mobile\/230225213253165315861.html",
        "thumbnail_pic_s":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x480_63fa0e0256b2d_mwpm_03201609.jpeg",
        "thumbnail_pic_s02":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x480_63fa0e033b47a_mwpm_03201609.jpeg",
        "thumbnail_pic_s03":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x288_63fa0e03e6481_mwpm_03201609.jpeg",
        "is_content":"1"
        },
        {
        "uniquekey":"92f32d5dbccebfd49415697821ba8653",
        "title":"常州金坛检察院开展检察开放日活动",
        "date":"2023-02-25 21:28:00",
        "category":"头条",
        "author_name":"科普社会",
        "url":"https:\/\/mini.eastday.com\/mobile\/230225212816298791171.html",
        "thumbnail_pic_s":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x427_63fa0cefb61b7_mwpm_03201609.jpeg",
        "is_content":"1"
        },
        {
        "uniquekey":"f1a36cdadd7a37c410dc9ecf8508f354",
        "title":"张家港市常阴沙现代农业示范园区开展冬训“第一课”",
        "date":"2023-02-25 21:27:00",
        "category":"头条",
        "author_name":"科普社会",
        "url":"https:\/\/mini.eastday.com\/mobile\/230225212716019771496.html",
        "thumbnail_pic_s":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x427_63fa0cb3790c5_mwpm_03201609.jpeg",
        "is_content":"1"
        },
        {
        "uniquekey":"0c86aa0f75a4a4326425b63332084bee",
        "title":"南京江北新区盘城街道永丰社区开启冬训“加法题”模式",
        "date":"2023-02-25 21:26:00",
        "category":"头条",
        "author_name":"科普社会",
        "url":"https:\/\/mini.eastday.com\/mobile\/230225212626383491792.html",
        "thumbnail_pic_s":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x480_63fa0c81dc285_mwpm_03201609.jpeg",
        "is_content":"1"
        },
        {
        "uniquekey":"07e6ea1d8ff07699f0074fa66c7126dc",
        "title":"苏州市相城区黄桥街道张庄村“集中学、特色学、实践学”",
        "date":"2023-02-25 21:24:00",
        "category":"头条",
        "author_name":"科普社会",
        "url":"https:\/\/mini.eastday.com\/mobile\/230225212418265232930.html",
        "thumbnail_pic_s":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x480_63fa0c01bfbb3_mwpm_03201609.jpeg",
        "is_content":"1"
        },
        {
        "uniquekey":"633310efa7a1c454f7f51946a4145ce6",
        "title":"儿童文学作家董恒波新作《神探鹰之队》推出",
        "date":"2023-02-25 21:23:00",
        "category":"头条",
        "author_name":"每日看点快看",
        "url":"https:\/\/mini.eastday.com\/mobile\/230225212347254805043.html",
        "thumbnail_pic_s":"https:\/\/dfzximg02.dftoutiao.com\/news\/20230225\/20230225212347_7911fc47be23c52bd6bad78da1abdc5c_1_mwpm_03201609.jpeg",
        "is_content":"1"
        },
        {
        "uniquekey":"9cec40eaa43537f6eb54019a8ddbae94",
        "title":"托育早教机构行政纠纷化解",
        "date":"2023-02-25 21:19:00",
        "category":"头条",
        "author_name":"科普社会",
        "url":"https:\/\/mini.eastday.com\/mobile\/230225211912915225900.html",
        "thumbnail_pic_s":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x427_63fa0ad057402_mwpm_03201609.jpeg",
        "is_content":"1"
        },
        {
        "uniquekey":"9b979950f4048e29d20f48b1b9e6bbdf",
        "title":"“大兵挖掘教师”掀起历史学习热潮",
        "date":"2023-02-25 21:15:00",
        "category":"头条",
        "author_name":"科普社会",
        "url":"https:\/\/mini.eastday.com\/mobile\/230225211511522749894.html",
        "thumbnail_pic_s":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x300_63fa09dc55181_mwpm_03201609.jpeg",
        "thumbnail_pic_s02":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x360_63fa09dd788de_mwpm_03201609.jpeg",
        "thumbnail_pic_s03":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x360_63fa09de279c9_mwpm_03201609.jpeg",
        "is_content":"1"
        },
        {
        "uniquekey":"115a4617333527e23806277d72d6e310",
        "title":"全国首家服务机器人应用体验中心落户扬州",
        "date":"2023-02-25 21:12:00",
        "category":"头条",
        "author_name":"科普社会",
        "url":"https:\/\/mini.eastday.com\/mobile\/230225211226382856642.html",
        "thumbnail_pic_s":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x480_63fa0939d4458_mwpm_03201609.jpeg",
        "is_content":"1"
        },
        {
        "uniquekey":"f401cbf171b056276a0fdfd93d305651",
        "title":"新疆日报报友分享会举办第五十九期活动：为老年人撑起一片爱的天空",
        "date":"2023-02-25 21:12:00",
        "category":"头条",
        "author_name":"每日看点快看",
        "url":"https:\/\/mini.eastday.com\/mobile\/230225211206543135676.html",
        "thumbnail_pic_s":"https:\/\/dfzximg02.dftoutiao.com\/news\/20230225\/20230225211206_783a9f66ed2cb71121944c3ea14906df_1_mwpm_03201609.jpeg",
        "is_content":"1"
        },
        {
        "uniquekey":"b4c13d01a22215f0b1649624e2f86459",
        "title":"句容：农机下乡为春耕生产提供保障",
        "date":"2023-02-25 21:07:00",
        "category":"头条",
        "author_name":"科普社会",
        "url":"https:\/\/mini.eastday.com\/mobile\/230225210739106877063.html",
        "thumbnail_pic_s":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x383_63fa0818e9b7b_mwpm_03201609.jpeg",
        "thumbnail_pic_s02":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x396_63fa0819c8188_mwpm_03201609.jpeg",
        "thumbnail_pic_s03":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x427_63fa081a99339_mwpm_03201609.jpeg",
        "is_content":"1"
        },
        {
        "uniquekey":"0d19cafeb48053f33489dde7344600fe",
        "title":"张俊杰：从专科医生到人大代表的“责任转化”",
        "date":"2023-02-25 21:05:00",
        "category":"头条",
        "author_name":"科普社会",
        "url":"https:\/\/mini.eastday.com\/mobile\/230225210526020713434.html",
        "thumbnail_pic_s":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x360_63fa07941251c_mwpm_03201609.jpeg",
        "thumbnail_pic_s02":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x480_63fa0794c6d76_mwpm_03201609.jpeg",
        "thumbnail_pic_s03":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x480_63fa07957f196_mwpm_03201609.jpeg",
        "is_content":"1"
        },
        {
        "uniquekey":"9dc99ba00726982ab7c5f518baa993dd",
        "title":"如皋海关助力企业开拓海外市场“锦上添花”",
        "date":"2023-02-25 21:04:00",
        "category":"头条",
        "author_name":"科普社会",
        "url":"https:\/\/mini.eastday.com\/mobile\/230225210429981825531.html",
        "thumbnail_pic_s":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x480_63fa075b45295_mwpm_03201609.jpeg",
        "thumbnail_pic_s02":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x427_63fa075c5d8ac_mwpm_03201609.jpeg",
        "thumbnail_pic_s03":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x427_63fa075d65bf5_mwpm_03201609.jpeg",
        "is_content":"1"
        },
        {
        "uniquekey":"74a34eec23541b3caf28d5f48f6c9d8d",
        "title":"南通崇川区启动实施“紫琅干将”工程",
        "date":"2023-02-25 21:03:00",
        "category":"头条",
        "author_name":"科普社会",
        "url":"https:\/\/mini.eastday.com\/mobile\/230225210345149204949.html",
        "thumbnail_pic_s":"",
        "is_content":"1"
        },
        {
        "uniquekey":"b6804ff42e018f0a087a702a4251a5d9",
        "title":"张家港高新区（塘桥镇）刘村村党总支开启文明“密钥”",
        "date":"2023-02-25 21:03:00",
        "category":"头条",
        "author_name":"科普社会",
        "url":"https:\/\/mini.eastday.com\/mobile\/230225210322964787369.html",
        "thumbnail_pic_s":"https:\/\/dfzximg02.dftoutiao.com\/minimodify\/20230225\/640x301_63fa071a70094_mwpm_03201609.jpeg",
        "is_content":"1"
        },
        {
        "uniquekey":"84a7597c355f904f058dcc7fc3c7562b",
        "title":"张家港市高新区（塘桥镇）馨塘社区党支部开展理论宣讲",
        "date":"2023-02-25 21:02:00",
        "category":"头条",
        "author_name":"科普社会",
        "url":"https:\/\/mini.eastday.com\/mobile\/230225210259349375107.html",
        "thumbnail_pic_s":"",
        "is_content":"1"
        },
        {
        "uniquekey":"bbf19dfef6e9775b71ad6104b4f18ba6",
        "title":"李秀生：树立正确的金融价值观",
        "date":"2023-02-25 21:01:00",
        "category":"头条",
        "author_name":"每日看点快看",
        "url":"https:\/\/mini.eastday.com\/mobile\/230225210152547769857.html",
        "thumbnail_pic_s":"https:\/\/dfzximg02.dftoutiao.com\/news\/20230225\/20230225210152_217cc52a8794ce038d69f0520846b7aa_1_mwpm_03201609.jpeg",
        "is_content":"1"
        },
        {
        "uniquekey":"5ac6ecf6f31d1c0054716c85465bd6b6",
        "title":"不动产登记柜台摆进小区，居民用手机操作不到一小时能领证",
        "date":"2023-02-25 20:47:00",
        "category":"头条",
        "author_name":"每日看点快看",
        "url":"https:\/\/mini.eastday.com\/mobile\/230225204701606634474.html",
        "thumbnail_pic_s":"https:\/\/dfzximg02.dftoutiao.com\/news\/20230225\/20230225204701_f40e6d666656797ded29100158101917_1_mwpm_03201609.jpeg",
        "thumbnail_pic_s02":"https:\/\/dfzximg02.dftoutiao.com\/news\/20230225\/20230225204701_f40e6d666656797ded29100158101917_2_mwpm_03201609.jpeg",
        "thumbnail_pic_s03":"https:\/\/dfzximg02.dftoutiao.com\/news\/20230225\/20230225204701_f40e6d666656797ded29100158101917_3_mwpm_03201609.jpeg",
        "is_content":"1"
        },
        {
        "uniquekey":"806b51c1e790feedffd7dd22652bd6b8",
        "title":"【高质量发展看中国｜粤企会客厅】创新、绿色 这家钢铁企业迈向高质量",
        "date":"2023-02-25 20:43:00",
        "category":"头条",
        "author_name":"人民网-人民视频，供稿：人民资讯",
        "url":"https:\/\/mini.eastday.com\/mobile\/230225204328254492061.html",
        "thumbnail_pic_s":"",
        "is_content":"1"
        }
        ],
        "page":"1",
        "pageSize":"30"
        },
        "error_code":0
        }
     */
    // http://v.juhe.cn/toutiao/index?type=top&key=96552e4bd2888435352d77483d647a64
    Response response = await Dio().get("http://v.juhe.cn/toutiao/index?type=top&key=96552e4bd2888435352d77483d647a64");
    NewsTodayModel model = NewsTodayModel.fromJson(response.data);
    emit(state.setModel(model));
  }
}
